<?php
namespace app\admin\model;

use think\Model;
                    

class GoodsOrder extends Model
                    
{
                    
    public function getAll($where){
                    
        $rs = GoodsOrder::where($where)

        ->alias('go')

        ->order('status asc')

        ->order('create_time desc')

        ->join('app_goods g','go.g_id = g.id','LEFT')

         ->field('go.*,g.img')
                    
        ->paginate(10);
                    
        return $rs;
                    
    }
                    
    public function getOne($where){
                    
        $rs = GoodsOrder::where($where)
                    
        ->find();
                    
        return $rs;
                    
    }
                    
    public function add($data){
                    
        $rs = GoodsOrder::data($data)
                    
        ->save();
                    
        return $rs;
                    
    }
                    
    public function edit($where,$data){
                    
        $rs = GoodsOrder::where($where)
                    
        ->update($data);
                    
        return $rs;
                    
    }
                    
    public function del($where){
                    
        $rs = GoodsOrder::where($where)
                    
        ->delete();
                    
        return $rs;
                    
    }

    public function totalNum(){
        $rs = GoodsOrder::count('id');
        return $rs;
    }

    public function totalNumWhere($where){
        $rs = GoodsOrder::where($where)
            ->count('id');
        return $rs;
    }
}
                    
